home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_7_6.arc / TOMPEEK.C < prev    next >
C/C++ Source or Header  |  1989-07-31  |  1KB  |  68 lines

  1. /* 
  2.  * tompeek.c 
  3.  *
  4.  * High memory peek utility
  5.  *
  6.  * This program returns a screen dump of ram (by byte) at the provided
  7.  * linear (which is also physical) address for the provided number of bytes.
  8.  *
  9.  *        Compiled using Microsoft C 5.1
  10.  * 
  11.  */
  12. #include <stdio.h>
  13. #include <dos.h>
  14.  
  15. /* Main function.
  16.  *
  17.  * Check command line information, and perform the appropriate hex-dump
  18.  * 
  19.  */
  20. main(argc, argv)
  21. int    argc;
  22. char    **argv;
  23. {
  24.     short    size;
  25.     long    source;
  26.     void    tomPeek(long,short);
  27.  
  28.     if(argc==3)
  29.         {
  30.         sscanf(argv[1],"%lx",&source);
  31.         sscanf(argv[2],"%x",&size);
  32.         tomPeek(source,size);
  33.         }
  34.     else
  35.         {
  36.         printf("usage: TomPeek <address> <size>\n");
  37.         }
  38.  
  39. }
  40.  
  41. /*
  42.  *    tomPeek -    Dump the memory at linear address "source" for "size" bytes
  43.  *                    of sixteen-byte lines
  44.  */
  45. void    tomPeek(source,size)
  46. long    source;
  47. short    size;
  48. {
  49.     char    peekBuf[16];
  50.     short    i,j,k;
  51.     extern short near    get_high_mem(char *,short,long);
  52.  
  53.     for(i=0;i<size;i+=16)
  54.         {
  55.         j = size-i;
  56.         if(j>16)
  57.             j = 16;
  58.         get_high_mem(peekBuf,j,source);
  59.         source += j;
  60.         for(k=0;k<j;k++)
  61.             {
  62.             printf("%02X ",((short)(peekBuf[k]))&0xFF);
  63.             }
  64.         printf("\n");
  65.         }
  66. }
  67.  
  68.